package org.leumasjaffe.initiativeTracker.entity.trap;

import mathematics.probability.NormalRV;

import org.eclipse.jdt.annotation.NonNull;

import tools.Pair;

/**
 * A trap to represent the launching of a fireball or similar spell
 * @author Sam Jaffe
 *
 */
public class SpellBurstTrap extends RandomTrap {
	private double accuracy = 1;

	public SpellBurstTrap() {
		super(NormalRV.standard);
	}
	
	/**
	 * Generates a SpellBurstTrap with a given accuracy factor
	 * @param accuracy The percent (or 1/percent) accuracy, (standard accuracy is high enough already).
	 */
	public SpellBurstTrap(double accuracy) {
		super(NormalRV.standard);
		if (accuracy <= 1)
			this.accuracy = accuracy;
		else
			this.accuracy = 1.0/(double) accuracy;
	}

	@Override
	public @NonNull String getName() {
		return "Spellburst Trap";
	}

	@Override
	public void activate() {
		Pair<Double, Double> xy = ((NormalRV) this.r[0]).boxMuller();
		double x = xy.getT()/this.accuracy;
		double y = xy.getS()/this.accuracy;
		print((int) x, (int) y);
	}
	
	private static void print(int x, int y) {
		System.out.println("The spellburst hits the (offset) coordinates of (" + x + "," + y + ")");
	}


}
